package com.ruoyi.electronicFence.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.electronicFence.domain.TEfAlarms;
import com.ruoyi.electronicFence.service.ITEfAlarmsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警  （弃用）
 *
 * @author sxygsj
 * @date 2024-05-17
 */
@RestController
@RequestMapping("/electronicFence/alarms")
public class TEfAlarmsController extends BaseController
{
    @Autowired
    private ITEfAlarmsService tEfAlarmsService;

    /**
     * 查询电子围栏报警信息列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:alarms:list')")
    @GetMapping("/list")
    public TableDataInfo list(TEfAlarms tEfAlarms)
    {
        startPage();
        List<TEfAlarms> list = tEfAlarmsService.selectTEfAlarmsList(tEfAlarms);
        return getDataTable(list);
    }

    /**
     * 导出电子围栏报警信息列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:alarms:export')")
    @Log(title = "电子围栏报警信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TEfAlarms tEfAlarms)
    {
        List<TEfAlarms> list = tEfAlarmsService.selectTEfAlarmsList(tEfAlarms);
        ExcelUtil<TEfAlarms> util = new ExcelUtil<TEfAlarms>(TEfAlarms.class);
        util.exportExcel(response, list, "电子围栏报警信息数据");
    }

    /**
     * 获取电子围栏报警信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:alarms:query')")
    @GetMapping(value = "/{idId}")
    public AjaxResult getInfo(@PathVariable("idId") Long idId)
    {
        return success(tEfAlarmsService.selectTEfAlarmsByIdId(idId));
    }

    /**
     * 新增电子围栏报警信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:alarms:add')")
    @Log(title = "电子围栏报警信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TEfAlarms tEfAlarms)
    {
        return toAjax(tEfAlarmsService.insertTEfAlarms(tEfAlarms));
    }

    /**
     * 修改电子围栏报警信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:alarms:edit')")
    @Log(title = "电子围栏报警信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TEfAlarms tEfAlarms)
    {
        return toAjax(tEfAlarmsService.updateTEfAlarms(tEfAlarms));
    }

    /**
     * 删除电子围栏报警信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:alarms:remove')")
    @Log(title = "电子围栏报警信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{idIds}")
    public AjaxResult remove(@PathVariable Long[] idIds)
    {
        return toAjax(tEfAlarmsService.deleteTEfAlarmsByIdIds(idIds));
    }
}
